﻿using Lis.IBLL;
using Lis.IRepository;
using Lis.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Lis.BLL
{
    public class BookDetailService:BaseService<BookDetail>,IBookDetailService
    {
        #region 01，根据docnumber查询图书详情+ServiceResult<IEnumerable<object>> GetEntityByDocNumber(string docNumber)
        /// <summary>
        /// 根据docnumber查询图书详情
        /// </summary>
        /// <param name="docNumber">docnumber</param>
        /// <returns></returns>
        public ServiceResult<IEnumerable<object>> GetEntityByDocNumber(string docNumber)
        {
            if (!string.IsNullOrEmpty(docNumber))
            {
                return new ServiceResult<IEnumerable<object>>()
                {
                    Success = true,
                    Result = ((IBookDetailRepository)DBSession.SysBookDetailRepository).GetEntitiesByDocNumber(docNumber),
                    Message = "",
                    Code = "10000"
                };
            }
            else
            {
                return new ServiceResult<IEnumerable<object>>()
                {
                    Success = false,
                    Result = null,
                    Message = "请输入正确的docnumber进行查询",
                    Code = "10001"
                };
            }
        } 
        #endregion
        #region 02，分页查询+override IQueryable<BookDetail> GetPageEntities<S>(int pageSize, int pageIndex, out int total, bool isAsc, System.Linq.Expressions.Expression<Func<BookDetail, bool>> whereLambda, System.Linq.Expressions.Expression<Func<BookDetail, S>> orderByLambda)
        /// <summary>
        /// 分页查询
        /// </summary>
        /// <typeparam name="S"></typeparam>
        /// <param name="pageSize">页大小</param>
        /// <param name="pageIndex">页码</param>
        /// <param name="total">总条数</param>
        /// <param name="isAsc">是否倒序</param>
        /// <param name="whereLambda">查询Lambda</param>
        /// <param name="orderByLambda">排序Lamdba</param>
        /// <returns></returns>
        public override IQueryable<BookDetail> GetPageEntities<S>(int pageSize, int pageIndex, out int total, bool isAsc, System.Linq.Expressions.Expression<Func<BookDetail, bool>> whereLambda, System.Linq.Expressions.Expression<Func<BookDetail, S>> orderByLambda)
        {
            throw new NotImplementedException();
        } 
        #endregion

        public override bool Add(BookDetail entity)
        {
            throw new NotImplementedException();
        }

        public override bool UpDate(BookDetail entity)
        {
            throw new NotImplementedException();
        }

        public override bool Delete(BookDetail entity)
        {
            throw new NotImplementedException();
        }

        #region 03，根据馆藏号查询图书详细信息+ServiceResult<IEnumerable<object>> GetEntitiesByBarCode(string barCode)
        /// <summary>
        /// 根据馆藏号查询图书详细信息
        /// </summary>
        /// <param name="barCode">馆藏号</param>
        /// <returns></returns>
        public ServiceResult<IEnumerable<object>> GetEntitiesByBarCode(string barCode)
        {
            if (!string.IsNullOrEmpty(barCode))
            {
                return new ServiceResult<IEnumerable<object>>()
                {
                    Success = true,
                    Result = ((IBookDetailRepository)DBSession.SysBookDetailRepository).GetEntitiesByBarCode(barCode),
                    Message = "",
                    Code = "10000"
                };
            }
            else
            {
                return new ServiceResult<IEnumerable<object>>()
                {
                    Success = false,
                    Result = null,
                    Message = "请输入正确的馆藏号进行查询",
                    Code = "10001"
                };
            }
        } 
        #endregion
    }
}
